package com.sbeam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sbeam.pojo.Factory;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface FactoryMapper extends BaseMapper<Factory> {
    Factory getFactoryById(Integer factoryId);

    List<Factory> findFactoryByName(Map map);

    @Select("select * from factory")
    List<Factory> getFactoryList();

    @Insert("insert into factory values(null,#{factoryName},#{introduce},#{status},#{images},#{created},#{updated})")
    int addFactory(Factory factory);

    @Update("update factory set status=#{status},updated=#{updated} where id = #{id}")
    int updateFactoryStatus(Factory factory);

    @Update("update factory set factory_name=#{factoryName},introduce=#{introduce},updated=#{updated} where id=#{id}")
    int updateFactory(Factory factory);

    @Delete("delete from factory where id=#{id}")
    int deleteFactoryById(Integer id);

    @Select("select count(1) from factory where factory_name like #{key}")
    int findTotal(String key);
}
